﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WeChat.Web.Filter
{
    #region LoginInfo

    /// <summary>
    /// 登录信息
    /// </summary>
    public class LoginInfo
    {
        /// <summary>
        /// 当前管理员Cookie
        /// </summary>
        public static HttpCookie OperaterInfoCookie
        {
            get
            {
                var request = HttpContext.Current.Request;
                return request.Cookies["OperaterInfo"];
            }
        }

        /// <summary>
        /// 获取管理员信息（解析存储的Cookie信息）
        /// </summary>
        /// <returns></returns>
        //public static OperaterEntity GetOperaterInfo()
        //{
        //    try
        //    {
        //        if (OperaterInfoCookie != null)
        //        {
        //            string jsonOperatorCookie = OperaterInfoCookie.Value;
        //            using (DscfBIServerConractClient client = new DscfBIServerConractClient())
        //                return client.GetOperaterInfoByCookie(jsonOperatorCookie, ParmsConfig.PlatId);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        LogHelper.WriteLog(ex.GetType(), ex);
        //    }

        //    return new OperaterEntity();
        //}

        /// <summary>
        /// 获取具有操作权限的管理员 如：管理员1,管理员2,管理员3
        /// </summary>
        /// <param name="arr"></param>
        /// <returns></returns>
        //public static string GetOperaterListString(OperaterEntity[] arr)
        //{
        //    if (arr == null || arr.Length == 0)
        //        return GetOperaterInfo().Id.ToString();

        //    string rString = string.Join(",", arr.Select(n => n.Id).ToArray());
        //    return rString;
        //}
    }

    #endregion
}